package com.songchaojie.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.songchaojie.dao.SupermarketDao;
import com.songchaojie.entity.City;
import com.songchaojie.entity.Factory;
import com.songchaojie.entity.Supermarket;
import com.songchaojie.service.SupermarketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SupermarketServiceImpl implements SupermarketService {

    @Autowired
    SupermarketDao supermarketDao;

    @Override
    public PageInfo<Supermarket> list(Supermarket supermarket, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Supermarket> list = supermarketDao.list(supermarket);
        return new PageInfo<>(list);
    }

    @Override
    public Integer add(Supermarket supermarket) {
        return supermarketDao.add(supermarket);
    }

    @Override
    public List<Factory> listFactory() {
        return supermarketDao.listFactory();
    }

    @Override
    public List<City> listCity(Integer pid) {
        return supermarketDao.listCity(pid);
    }
}
